<?php
	require 'membersession.class.php';
	require 'admin/sql.class.php';
	$arr = MemberSessionInfo::checkMemberLogin();
	if (is_null($arr)) {
		$currentMobile = "";
		$currentPassword = "";
		$currentAvatar = "";
		$currentGender = 0;
		$currentUsername = "";
		$currentNickname = "";
	} else {
		$currentMobile = $arr["mobile"];
		$currentPassword = $arr["password"];
		$currentAvatar = $arr["avatar"];
		$currentGender = $arr["gender"];
		$currentUsername = $arr["username"];
		$currentNickname = $arr["nickname"];
	}
?>
<!DOCTYPE html>
<html>
<head>
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="/mcnews/css/mcnews.css">
</head>
<script type="text/javascript">
	function checkLoginState(needShow, type) {
		var currentType = "registerMaskView";
		var display = "none";
		if (type == 1) {
			currentType = "loginMaskView"
		}

		if (needShow == true) {
			display = "inline";
		}
		document.getElementById(currentType).style.display=display;
	}

	function showLogin() {
		checkLoginState(true, 1);
	}

	function dissmissLogin() {
		checkLoginState(false, 1);
	}

	function showRegister() {
		checkLoginState(true, 0);
	}

	function dissmissRegister() {
		checkLoginState(false, 0);
	}
</script>

<body>

<div class="loginMaskView" id="loginMaskView" onclick="dissmissLogin();">
	<div class="loginSubView">
		<iframe class="loginView" src="login.php" frameborder="0"></iframe>
	</div>
</div>

<div class="loginMaskView" id="registerMaskView" onclick="dissmissRegister();">
	<div class="loginSubView">
		<iframe class="loginView" src="register.php" frameborder="0"></iframe>
	</div>
</div>

<div class="header">
	<?php 
		$h = "";
		if (empty($currentMobile)) {
			$h = "<div class='rightbutton'>
					<a onclick='showLogin();'>登录</a>
					<a onclick='showRegister();'>注册</a>
				</div>";
		} else {
			$h = "<div class='rightbutton'>
					<img src='" . $currentAvatar . "'>
					<a href='member/index.php'>" . $currentMobile . "</a>
					<a href='outlogin.php'>退出</a>
				</div>";
		}
		echo $h;
	?>	
</div>

<div class="divbody">
	<!--导航栏-->
	<div class="nav">
     <ul>
       <li style="background-color: blue"><a href="index.php">首页</a></li>
       <li><a href="#">文章</a></li>
       <li><a href="#">故事</a></li>
       <li><a href="#">散文</a></li>
       <li><a href="#">诗歌</a></li>
       <li><a href="#">日记</a></li>
       <li><a href="#">小说</a></li>
      </ul>
	</div>

	<!-- 内容 -->
	<div class="content">
		<div class="leftContent">
			<div class="newList">
				<ul>
					<li><span><a href="list.php?type=0">更多</a></span>最新文章</li>
					<?php 
						$arr = getContentInfoFrom(10);
						//var_dump($arr);

						foreach ($arr as $key => $value) {
							echo "<li><span>" . $value["createTime"] . "</span><a href='detail.php?id=" . $value["id"] . "'>" . $value["title"] . "</a></li>";
						}
					?>
				</ul>
			</div>
			<div class="readList">
				<ul>
					<li><span><a href="list.php?type=1">更多</a></span>阅读点击</li>
					<?php 
						$arr = getContentInfoFrom(10);
						//var_dump($arr);

						foreach ($arr as $key => $value) {
							echo "<li><span>" . $value["createTime"] . "</span><a href='detail.php?id=". $value["id"] ."'>" . $value["title"] . "</a></li>";
						}
					?>
				</ul>
			</div>
		</div>
		<div class="rightContent">
		个人资料
		<?php
			echo "<br/>手机号:" . $currentMobile;
			echo "<br/>用户名:" . $currentUsername;
			echo "<br/>昵称:" . $currentNickname;
			echo "<br/>性别:";
			echo $currentGender == 0 ? "男" : "女";
			echo "<br/><img style='width:40px; height:40px;' src='" . $currentAvatar . "'>";
		?>
		</div>
	</div>

	<div class="content">
		<div class="leftContent">
			<div class="newList">
				<ul>
					<li><span><a href="list.php?type=2">更多</a></span>最新文章</li>
					<?php 
						$arr = getContentInfoFrom(10);
						//var_dump($arr);

						foreach ($arr as $key => $value) {
							echo "<li><span>" . $value["createTime"] . "</span><a href='detail.php?id=" . $value["id"] . "'>" . $value["title"] . "</a></li>";
						}
					?>
				</ul>
			</div>
			<div class="readList">
				<ul>
					<li><span><a href="list.php?type=3">更多</a></span>阅读点击</li>
					<?php 
						$arr = getContentInfoFrom(10);
						//var_dump($arr);

						foreach ($arr as $key => $value) {
							echo "<li><span>" . $value["createTime"] . "</span><a href='detail.php?id=" . $value["id"] . "'>" . $value["title"] . "</a></li>";
						}
					?>
				</ul>
			</div>
		</div>
		<div class="rightContent">右边展览
			<marquee onmouseover="stop()" onmouseout="start()" direction="up" scrollamount="3" height="200">
                     <ul>
                      <li><a href="#">中华五千年........[2016-05-27]</a></li>
                   
                      <li><a href="#">中华五中华五千年训........[2016-06-04]</a></li>
                   
                      <li><a href="#">中华五千年........[2016-06-06]</a></li>
                   
                      <li><a href="#">中华五千年........[2016-06-06]</a></li>
                   
                      <li><a href="#">中华五千年........[2016-06-20]</a></li>
                   
                      <li><a href="#">sdf年........[2016-06-17]</a></li>
                   
                      <li><a href="#">sdaf第三方阿斯蒂芬.....[2016-05-22]</a></li>

                      <li><a href="#">中华五千年........[2016-06-06]</a></li>
                   
                      <li><a href="#">中华五千年........[2016-06-06]</a></li>
                   
                      <li><a href="#">中华五千年........[2016-06-20]</a></li>
                   
                      <li><a href="#">sdf年........[2016-06-17]</a></li>
                   
                      <li><a href="#">sdaf第三方阿斯蒂芬.....[2016-05-22]</a></li>
                  </ul>
            </marquee>
		</div>
	</div>

	<!-- 作者 -->
	<div class="content">
		<div class="author">
			作者推荐
			<ul>
				<?php
					$arr = getMemberInfoWithNum(30);
					foreach ($arr as $key => $value) {
						echo "<li><a href=''><img src='" . $value["avatar"] . "'><p>" . $value["nickname"] . "</p></a></li>";
					}
				?>
			</ul>
		</div>
		<div class="">
		<form method="get" action="#">
			<input type="email" name="">
			<input type="submit" name="">
		</form>
		</div>
	</div>


	<div class="footer">footer</div>

</div>

</body>
</html>